package org.wuliu.Controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.wuliu.dao.HezhongDao;
import org.wuliu.dao.YeweuDao;
import org.wuliu.pojo.Hezhong;
import org.wuliu.pojo.Yeweu;
import org.wuliu.utils.ResponseResult;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/hezong")
@CrossOrigin(value = "*")
public class HezhongContrller {
    @Autowired
    HezhongDao hezhongDao;
    @Autowired
    YeweuDao yeweuDao;
    @RequestMapping("/list")
    @ResponseBody
    public ResponseResult list(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "5") int limit) throws  Exception{
        Page<Hezhong> pager = PageHelper.startPage(page,limit);
        List<Yeweu> list= yeweuDao.getAlls();
        return new ResponseResult(pager.getTotal(),list);
    }
}
